/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gameheart.client.sprite;

/**
 *
 * @author win7
 */
public class SynMessage {

    private String _message = "typing message";
    private int _maxNumber = -1;

    public SynMessage(int maxNumber) {
        _maxNumber = maxNumber;
    }
    public SynMessage(int maxNumber, String initString)
    {
        _maxNumber = maxNumber;
        _message = new String(initString);
    }

    public synchronized String getMessage() {
        return new String(_message);
    }

    public synchronized void addChar(char c) {
        if (_message.length() < _maxNumber) {
            _message = _message.concat(String.valueOf(c));
        }
    }

    public synchronized void removeChar() {
        if (_message.length() > 0) {
            _message = _message.substring(0, _message.length() - 1);
        }
    }
    public synchronized void  Clear()
    {
        _message = "";
    }
}
